//
//  ZLViewController.m
//  ZLPlateNumberInputView
//
//  Created by zzl on 06/28/2023.
//  Copyright (c) 2023 zzl. All rights reserved.
//

#import "ZLViewController.h"
#import <ZLPlateNumberInputView/ZLPlateNumberInputView.h>

@interface ZLViewController ()
@property (nonatomic, strong) ZLPlateNumberInputView *inputView;
@property (nonatomic, strong) UITextField *textField;
@end

@implementation ZLViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.inputView = [[ZLPlateNumberInputView alloc] initWithFrame:CGRectMake(10, 100, self.view.bounds.size.width - 20, 50)];
    [self.view addSubview:self.inputView];
    __weak __typeof(self)weakSelf = self;
    self.inputView.tapBlock = ^{
        [weakSelf.textField becomeFirstResponder];
    };
    
    self.textField = [[UITextField alloc] initWithFrame:CGRectMake(10, 300, self.view.bounds.size.width - 20, 50)];
    self.textField.backgroundColor = [UIColor grayColor];
    [self.textField addTarget:self action:@selector(calueChange) forControlEvents:UIControlEventEditingChanged];
    [self.view addSubview:self.textField];
}

- (void)calueChange {
    self.inputView.plateNumber = self.textField.text;
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    self.inputView.editing = NO;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
